home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / TextG.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  5.4 KB  |  165 lines

  1. /*
  2.  * (c) Copyright 1995, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  * Permission to use, copy, modify, and distribute this software for
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  *
  25.  * US Government Users Restricted Rights
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * Author: John Spitzer, SGI Applied Engineering
  36.  *
  37.  */
  38.  
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. #include "FuncEnum.h"
  42. #include <malloc.h>
  43.  
  44. /* This will be set by compile time #defines                     */
  45. /* They control the size and functionality of the code generated */
  46. #ifdef FULL_COLOR_PATHS
  47.   #define MAX_COLOR_DIM 4
  48. #else
  49.   #define MAX_COLOR_DIM 3
  50. #endif
  51. #ifdef FULL_RASTERPOS_PATHS
  52.   #define MIN_RPOS_DIM 2
  53. #else
  54.   #define MIN_RPOS_DIM 3
  55. #endif
  56. #ifdef FULL_FUNCPTR_PATHS
  57.   #define FUNC_PTRS 1
  58. #else
  59.   #define FUNC_PTRS 0
  60. #endif
  61.  
  62. char* visualSuccinct[] = {
  63.     "Idx",
  64.     "RGB"
  65. };
  66.  
  67. char* colorSuccinct[] = {
  68.     "n",
  69.     "r",
  70. };
  71.  
  72. char* pntSuccinct[] = {
  73.     "Pf",
  74.     "Pt"
  75. };
  76.  
  77. char* miSuccinct[] = {
  78.     "One",
  79.     "Multi"
  80. };
  81.  
  82. char* visualVerbose[] = {
  83.     "CI",
  84.     "RGB"
  85. };
  86.  
  87. char* colorVerbose[] = {
  88.     "NONE",
  89.     "PER_RASTERPOS",
  90. };
  91.  
  92. char* PrintEntry(FILE *fp, int p, int rd, int mi, int c, int cd, int vis)
  93. {
  94.     char* funcName = (char*)malloc(64);
  95.     sprintf(funcName,"Text%s%s%sC%s%d%d", visualSuccinct[vis], pntSuccinct[p], miSuccinct[mi], colorSuccinct[c], rd, cd);
  96.     fprintf(fp,"#define FUNCTION %s\n", funcName);
  97.     if (p)
  98.         fprintf(fp,"#define FUNCTION_PTRS\n");
  99.     if (mi)
  100.         fprintf(fp,"#define MULTIIMAGE\n");
  101.     fprintf(fp,"#define RASTERPOS_DIM %d\n", rd);
  102.     fprintf(fp,"#define COLOR %s\n", colorVerbose[c]);
  103.     fprintf(fp,"#define COLOR_DIM %d\n", cd);
  104.     fprintf(fp,"#define VISUAL %s\n", visualVerbose[vis]);
  105.     fprintf(fp,"#include \"TextX.c\"\n");
  106.     fprintf(fp,"#undef FUNCTION\n");
  107.     fprintf(fp,"#undef VISUAL\n");
  108.     fprintf(fp,"#undef COLOR\n");
  109.     fprintf(fp,"#undef COLOR_DIM\n");
  110.     fprintf(fp,"#undef MULTIIMAGE\n");
  111.     fprintf(fp,"#undef FUNCTION_PTRS\n");
  112.     fprintf(fp,"#undef RASTERPOS_DIM\n");
  113.     fprintf(fp,"\n");
  114.     return funcName;
  115. }
  116.  
  117. #define TOTAL_FUNCS 2*2*2*2*2*2
  118.  
  119. main()
  120. {
  121.     TextFunc function;
  122.     int i;
  123.     int p,rd,mi,c,cd,vis;
  124.     FILE *fp, *header;
  125.     char* names[TOTAL_FUNCS];
  126.  
  127.     for (i=0; i<TOTAL_FUNCS; i++)
  128.         names[i] = "Noop";
  129.     header = fopen("TextX.h", "w");
  130.     fprintf(header, "/*\n * File TextX.h generated from TextG (source file TextG.c)\n */\n\n");
  131.     fp = fopen("TextF.c", "w");
  132.     fprintf(fp, "/*\n * File TextF.c generated from TextG (source file TextG.c)\n */\n\n");
  133.     fprintf(fp, "#include \"Text.h\"\n");
  134.     for (mi=0;mi<2;mi++) {
  135.         for (p=0;p<=FUNC_PTRS;p++) {
  136.             for (rd=MIN_RPOS_DIM;rd<=3;rd++) {
  137.                 for (c=0;c<2;c++) {
  138.                     for (vis=0;vis<2;vis++) {
  139.                         for (cd=3;cd<=MAX_COLOR_DIM;cd++) {
  140.                             function.word = 0;
  141.                             function.bits.rasterPosDim  = rd-2;
  142.                             function.bits.functionPtrs  = p;
  143.                             function.bits.multiimage    = mi;
  144.                             function.bits.colorData     = c;
  145.                             function.bits.visual        = vis;
  146.                             function.bits.colorDim      = cd-3;
  147.                             names[function.word] = PrintEntry(fp, p, rd, mi, c, cd, vis);
  148.                             fprintf(header, "void %s(TestPtr);\n", names[function.word]);
  149.                         }
  150.                     }
  151.                 }
  152.             }
  153.         }
  154.     }
  155.     fclose(fp);
  156.     fprintf(header, "void Noop(TestPtr);\n");
  157.     fprintf(header, "typedef void (*ExecuteFunc)(TestPtr);\n");
  158.     fprintf(header, "\nExecuteFunc TextExecuteTable[] = {\n");
  159.     for (i=0; i<TOTAL_FUNCS; i++)
  160.         fprintf(header, "    %s,\n", names[i]);
  161.     fprintf(header, "};\n");
  162.     fclose(header);
  163.     return 0;
  164. }
  165.